package com.irdstudio.cdp.pboc.service.impl;

import java.util.List;
import java.util.Objects;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.irdstudio.cdp.pboc.service.dao.PbocForcecarryDao;
import com.irdstudio.cdp.pboc.service.domain.PbocForcecarry;
import com.irdstudio.cdp.pboc.service.facade.PbocForcecarryService;
import com.irdstudio.cdp.pboc.service.vo.PbocForcecarryVO;
import com.irdstudio.basic.framework.core.base.FrameworkService;
/**
 * <p>ServiceImpl: 法院强制执行记录				<p>
 * @author ligm
 * @date 2018-12-26
 */
@Service("pbocForcecarryService")
public class PbocForcecarryServiceImpl implements PbocForcecarryService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(PbocForcecarryServiceImpl.class);

	@Autowired
	private PbocForcecarryDao pbocForcecarryDao;
	
	/**
	 * 新增操作
	 */
	public int insertPbocForcecarry(PbocForcecarryVO inPbocForcecarryVo)  throws Exception {
		logger.debug("当前新增数据为:"+ inPbocForcecarryVo.toString());
		int num = 0;
		try {
			PbocForcecarry pbocForcecarry = new PbocForcecarry();
			beanCopy(inPbocForcecarryVo, pbocForcecarry);
			num = pbocForcecarryDao.insertPbocForcecarry(pbocForcecarry);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("当前新增数据条数为:"+ num);
		return num;
	}

	/**
	 * 删除操作
	 */
	public int deleteByPk(PbocForcecarryVO inPbocForcecarryVo)  throws Exception {
		logger.debug("当前删除数据条件为:"+ inPbocForcecarryVo);
		int num = 0;
		try {
			PbocForcecarry pbocForcecarry = new PbocForcecarry();
			beanCopy(inPbocForcecarryVo, pbocForcecarry);
			num = pbocForcecarryDao.deleteByPk(pbocForcecarry);
		} catch (Exception e) {
			logger.error("删除数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocForcecarryVo +"删除的数据条数为"+ num);
		return num;
	}


	/**
	 * 更新操作
	 */
	public int updateByPk(PbocForcecarryVO inPbocForcecarryVo)  throws Exception {
		logger.debug("当前修改数据为:"+ inPbocForcecarryVo.toString());
		int num = 0;
		try {
			PbocForcecarry pbocForcecarry = new PbocForcecarry();
			beanCopy(inPbocForcecarryVo, pbocForcecarry);
			num = pbocForcecarryDao.updateByPk(pbocForcecarry);
		} catch (Exception e) {
			logger.error("修改数据发生异常!", e);
			num = -1;
			throw e;
		}
		logger.debug("根据条件:"+ inPbocForcecarryVo +"修改的数据条数为"+ num);
		return num;
	}
	
	/**
	 * 查询操作
	 */
	public PbocForcecarryVO queryByPk(PbocForcecarryVO inPbocForcecarryVo) {
		
		logger.debug("当前查询参数信息为:"+ inPbocForcecarryVo);
		try {
			PbocForcecarry queryPbocForcecarry = new PbocForcecarry();
			beanCopy(inPbocForcecarryVo, queryPbocForcecarry);
			PbocForcecarry queryRslPbocForcecarry = pbocForcecarryDao.queryByPk(queryPbocForcecarry);
			if (Objects.nonNull(queryRslPbocForcecarry)) {
				PbocForcecarryVO outPbocForcecarryVo = beanCopy(queryRslPbocForcecarry, new PbocForcecarryVO());
				logger.debug("当前查询结果为:"+ outPbocForcecarryVo.toString());
				return outPbocForcecarryVo;
			} else {
				logger.debug("当前查询结果为空!");
			}
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
			throw e;
		}
		return null;
	}


	/**
	 * 查询用户权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocForcecarryVO> queryAllOwner(PbocForcecarryVO pbocForcecarryVo)  throws Exception {

		logger.debug("当前查询本人所属数据信息的参数信息为:");
		List<PbocForcecarryVO> list = null;
		try {
			List<PbocForcecarry> pbocForcecarrys = pbocForcecarryDao.queryAllOwnerByPage(pbocForcecarryVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ pbocForcecarrys.size());
			pageSet(pbocForcecarrys, pbocForcecarryVo);
			list = (List<PbocForcecarryVO>) beansCopy(pbocForcecarrys, PbocForcecarryVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocForcecarryVO> queryAllCurrOrg(PbocForcecarryVO pbocForcecarryVo)  throws Exception {

		logger.debug("当前查询本人所属机构数据信息的参数信息为:");
		List<PbocForcecarry> pbocForcecarrys = pbocForcecarryDao.queryAllCurrOrgByPage(pbocForcecarryVo);
		logger.debug("当前查询本人所属机构数据信息的结果集数量为:"+pbocForcecarrys.size());
		List<PbocForcecarryVO> list = null;
		try {
			pageSet(pbocForcecarrys, pbocForcecarryVo);
			list = (List<PbocForcecarryVO>) beansCopy(pbocForcecarrys, PbocForcecarryVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}


	/**
	 * 查询当前机构及下属机构权限数据
	 */
	@SuppressWarnings("unchecked")
	public List<PbocForcecarryVO> queryAllCurrDownOrg(PbocForcecarryVO pbocForcecarryVo)  throws Exception {

		logger.debug("当前查询本人所属机构及以下数据信息的参数信息为:");
		List<PbocForcecarry> pbocForcecarrys = pbocForcecarryDao.queryAllCurrDownOrgByPage(pbocForcecarryVo);
		logger.debug("当前查询本人所属机构及以下数据信息的结果集数量为:"+ pbocForcecarrys.size());
		List<PbocForcecarryVO> list = null;
		try {
			pageSet(pbocForcecarrys, pbocForcecarryVo);
			list = (List<PbocForcecarryVO>) beansCopy(pbocForcecarrys, PbocForcecarryVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
			throw e;
		}
		
		return list;
	
	}
	
	
	/**
	 * 需求编号:2019D0519
	 * 问题编号:2019D0519
	 * 开发人员: caoxin
	 * 创建日期:2019/7/19
	 * 功能描述:通过fId查询法院强制执行记录
	 * 修改日期:2019/7/19
	 * 修改描述:
	 */
//	@author:liuty
//	@date:2019/10/17
//	涉及产品:税e贷
//	功能:通过fId查询法院强制执行记录
//	原因:增量投产只投了接口没投实现，编译报错因此注释，不影响实际业务
//	public List<PbocForcecarryVO> queryByReportId(PbocForcecarryVO pbocForcecarryVo)  throws Exception {
//
//		logger.debug("当前查询本人法院强制执行记录为:");
//		List<PbocForcecarryVO> list = null;
//		try {
//			List<PbocForcecarry> pbocForcecarrys = pbocForcecarryDao.queryByReportId(pbocForcecarryVo);
//			logger.debug("当前查询本人法院强制执行记录为:"+ pbocForcecarrys.size());
//			pageSet(pbocForcecarrys, pbocForcecarryVo);
//			list = (List<PbocForcecarryVO>) beansCopy(pbocForcecarrys, PbocForcecarryVO.class);
//		} catch (Exception e) {
//			logger.error("数据转换出现异常!", e);
//			throw e;
//		}
//		
//		return list;
//	
//	}

}
